Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
The execall npm package is used to execute a regular expression against a string and return an array of matches, each with the matched text and index. It is particularly useful when you need to find all occurrences of a pattern in a string, not just the first one.
Finding multiple matches
This feature allows you to find all matches of a regular expression in a string. The example code searches for all occurrences of one or more digits in the given text and logs the array of match objects.
const execall = require('execall');
const regex = /\d+/g;
const matches = execall(regex, 'There are 3 apples and 5 oranges.');
console.log(matches);
The match-all package is similar to execall in that it also finds all matches of a regular expression in a string. However, it returns an iterator of matches instead of an array. This can be more efficient for large strings or when you only need to process matches one by one.
This package is a polyfill for the String.prototype.matchAll method, which is now part of the standard JavaScript library. It provides functionality similar to execall by returning an iterator of all results matching a string against a regular expression. The main difference is that matchAll is a method on the String prototype, while execall is a standalone function.
Find multiple RegExp matches in a string
Instead of having to iterate over RegExp#exec
, immutable, and with a nicer result format.
$ npm install execall
const execall = require('execall');
execall(/(\d+)/g, '$200 and $400');
/*
[
{
match: '200',
subMatches: ['200'],
index: 1
},
{
match: '400',
subMatches: ['400'],
index: 10
}
]
*/
Returns an object[]
with a match, sub-matches, and index.
Type: RegExp
Regular expression to match against the string
.
Type: string
MIT © Sindre Sorhus
FAQs
Find multiple RegExp matches in a string
We found that execall demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.